package demo1221.homework;

import java.util.Objects;

/*
编写一个类Book,具有name,price,press,author;
 */
public class Book implements Comparable<Book>{
    private String name;
    private Double price;
    private String press;
    private String outhor;

    public Book(String name, Double price, String press, String outhor) {
        this.name = name;
        this.price = price;
        this.press = press;
        this.outhor = outhor;
    }

    public Book() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getPress() {
        return press;
    }

    public void setPress(String press) {
        this.press = press;
    }

    public String getOuthor() {
        return outhor;
    }

    public void setOuthor(String outhor) {
        this.outhor = outhor;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return Objects.equals(name, book.name) &&
                Objects.equals(price, book.price) &&
                Objects.equals(press, book.press) &&
                Objects.equals(outhor, book.outhor);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, price, press, outhor);
    }

    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", price=" + price +
                ", press='" + press + '\'' +
                ", outhor='" + outhor + '\'' +
                '}';
    }

    @Override
    public int compareTo(Book o) {
        return this.price.compareTo(o.price);
    }
}
